#!/usr/bin/env python

import random
import string
import sys
import unicodedata

number = int(sys.argv[1])
lang = sys.argv[2]


unicode_glyphs = ''.join(
    unichr(char)
    for char in xrange(1114112) # 0x10ffff + 1
    if unicodedata.category(unichr(char))[0] in ('LMNPSZ')
)


def letter():
  length = random.choice(range(1,4))
  return ''.join(random.choice(string.letters) for x in range(length))

def digit():
  length = random.choice(range(1,4))
  return ''.join(random.choice(string.digits) for x in range(length))

def printable():
  return random.choice(string.printable)

def any_unicode():
  return random.choice(unicode_glyphs)




for i in xrange(number):
  nparts = random.choice(range(1,5))
  parts = []
  for part in range(nparts):
    func = random.choice((letter,digit,printable,any_unicode))
    parts.append(func())
  term = ''.join(parts)
  term = term.replace("\t", " ").replace("\n", " ") # don't break TSV syntax :)
  print ("\t".join((term,lang))).encode('UTF-8')
